@extends('admin::layouts.master ')
@section('content')

<div class="col-lg-12">
    <div class="card card-table">
        <div class="card-header"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">用户管理



                    {{--模态按钮--}}
                    <div>
                        <button data-toggle="modal" data-target="#addUser" type="button" class="btn btn-space btn-primary">用户列表</button>
                        <button data-toggle="modal" data-target="#addUser" type="button" class="btn btn-space btn-primary">添加用户</button>
                    </div>




                    {{--调用引入组件的模板方法来引入某个组件模板--}}
                    {{--@component第二个参数数组中的键名,会自动的变成变量名,传递到被调用的组件模板中去--}}
                    @component('components.modal',['title' => '添加用户','url' => '/admin/adminuser','id' => 'addUser'])
                    <div class="form-group">
                        <label>用户名</label>
                        <input type="text"   name="name" placeholder="请填写用户名" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>用户昵称</label>
                        <input type="text"  name="nickname" placeholder="请填写用户昵称" class="form-control">
                    </div>
                    <div class="form-group">
                        <label>密码</label>
                        <input type="password" name="password" placeholder="请填写密码" class="form-control">
                    </div>
                @endcomponent
                    {{--模态按钮--}}





                </font></font><div class="tools dropdown"><a href="#" role="button" data-toggle="dropdown" class="dropdown-toggle">
                <div role="menu" class="dropdown-menu"><a href="#" class="dropdown-item">Action</a><a href="#" class="dropdown-item">Another action</a><a href="#" class="dropdown-item">Something else here</a>
                    <div class="dropdown-divider"></div><a href="#" class="dropdown-item">Separated link</a>
                </div>
            </div>
        </div>
        <div class="card-body">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>昵称</th>
                    <th>创建时间</th>
                    <th>操作</th>
                    <th class="actions"></th>
                </tr>
                </thead>
                <tbody>
                @foreach($admins as $k=>$v)
                <tr>
                    <td>{{$v['id']}}</td>
                    <td>{{$v['name']}}</td>
                    <td>{{$v['nickname']}}</td>
                    <td>{{$v['created_at']}}</td>
                    {{--按钮--}}
                    <td class="actions">
                        <div class="btn-group btn-space">

                            {{--编辑模态框--}}
                            <button data-toggle="modal" data-target="#editUser{{$v['id']}}" type="button" class="btn btn-space btn-primary">
                                编辑
                            </button>
                            {{--调用引入组件的模板方法来引入模态框组件模板--}}
                            {{--@component第二个参数数组中的键名,会自动的变成变量名,传递到被调用的组件模板中去--}}
                            @component('components.modal',['title' => '编辑用户','url' => '/admin/adminuser/'.$v['id'],'id'=>'editUser'.$v['id'],'method' => 'PUT'])
                                {{--method=>PUT 参照路由表可知选择了资源路由中的updata方法--}}

                                <div class="form-group text-left" >
                                    <label>用户名</label>
                                    <input type="text" value="{{$v['name']}}" name="name" value="" placeholder="请填写用户名" class="form-control">
                                </div>

                                <div class="form-group text-left">
                                    <label>用户昵称</label>
                                    <input type="text" value="{{$v['nickname']}}" name="nickname" placeholder="请填写用户昵称" class="form-control">
                                </div>

                                <div class="form-group text-left">
                                    <label>密码</label>
                                    <input type="password" name="password" placeholder="请填写密码" class="form-control">
                                </div>

                            @endcomponent

                            {{--编辑模态框End--}}




                            <form action="/admin/adminuser/{{$v['id']}}" method="post">
                                @csrf
                                @method('DELETE')
                            <button type="submit" class="btn btn-danger">删除</button>
                            </form>

                            {{--分配角色按钮--}}
                            <a href="{{route('showRole',$v['id'])}}" class="btn btn-success ml-1">分配角色</a>
                        </div>
                    </td>

                </tr>
                @endforeach
                </tbody>
            </table>
        </div>
    </div>
    {{--分页显示--}}
    {{$admins->links()}}
</div>
@stop